blob: 485edf42be92b5de8e368e47964794109debbb98 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import { checkScope } from '$lib/auth';
import { redirect } from '@sveltejs/kit';
export const load = async (e) => {
const scopes = e.params.scopes
.split(' ')
.flatMap((v) => v.split(','))
.flatMap((v) => v.split('+'))
.filter((v) => v);
const session = await e.locals.auth();
const hasScopes: string[] = session.tokens.scope?.split(' ') ?? [];
if (checkScope(session, scopes, false)) throw redirect(303, '../..');
else
return {
missingScopes: scopes.filter((scope) => !hasScopes.includes(scope)),
};
};
|